#include "AudioRecordWindow.h"
#include <QFileDialog>
#include <QMessageBox>

AudioRecordWindow::AudioRecordWindow(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);
	this->setWindowTitle("Qt音频录制");
}
void AudioRecordWindow::choicePcmPath()
{
	QString mPath = QFileDialog::getSaveFileName(nullptr, "请选择输出文件地址(pcm)", "E:\\BaiduNetdiskDownload\\test_resource", "媒体文件(*.*)");
	ui.outPcmEdit->setText(mPath);
}
void AudioRecordWindow::startRecordAudioFunc()
{
	QString sampleRate = ui.sampleRateEdit->text();
	QString outPath = ui.outPcmEdit ->text();
	if (outPath.isEmpty()) {
		QMessageBox::warning(this, "温馨提示", "请选择文件输出路径");
		return;
	}
	AudioRecordThread::Get()->sampleRate = sampleRate.toInt();
	AudioRecordThread::Get()->outFilePath = outPath;
	AudioRecordThread::Get()->Start();
}

void AudioRecordWindow::stopRecordAudioFunc() {
	AudioRecordThread::Get()->Stop();
}

AudioRecordWindow::~AudioRecordWindow()
{
}
